﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PerfAnalyzerLib;

namespace PerfAnalyzerUI
{
	class DataGridViewHelpPerflogExport : DataGridViewHelper
	{ 
		public const string ColSelection = "col_PlExp_Selection";
		public const string ColPerflogFile = "col_PlExp_LogFile";

		public DataGridViewHelpPerflogExport(DataGridView trackedDataGridView, Form partentForm)
			: base(trackedDataGridView, partentForm)
		{
		}

		public override DataGridViewRow AddRow(object obj)
		{
			PerfLog perflog = (PerfLog)obj;

			_dataGridView.Rows.Add();
			int rowIndex = _dataGridView.RowCount - 1;
			DataGridViewRow row = _dataGridView.Rows[rowIndex];
			row.Cells[ColSelection].Value = true;
			row.Cells[ColPerflogFile].Value = perflog.Filename;
			row.Tag = perflog;
			_dataGridView.Refresh();

			TagToRow.Add(perflog, row);

			return row;
		}

		public override void AddRows(IEnumerable<object> tags)
		{
			throw new NotImplementedException();
		}

		public void RemoveRow(object obj)
		{
			_dataGridView.Rows.Remove(TagToRow[obj]);
			TagToRow.Remove(obj);
		}

		public override void RemoveRow(DataGridViewRow row)
		{
			throw new NotImplementedException();
		}

		public override void Clear()
		{
			_dataGridView.Rows.Clear();
			PerfLogManager.ClearPerflogList();
			TagToRow.Clear();
		}
	}
}
